<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var Stones = function (a, b, c) {
      // 对abc进行排序
      const [min, mid, max] = [a, b, c].sort((a, b) => a - b)
      // 默认res: 在三个值不是连接的情况 最少走2步，最多走 max - min - 2步
      const res = [2, max - min - 2]
      // min->mid 所需要走的步骤
      let step1 = mid - min - 1
      // mid->max 所需要走的步骤
      let step2 = max - mid - 1
      if (step1 === 0 && step2 === 0) {
        // 若两个都是零情况 minStep改成0
        res[0] = 0
      } else if (step1 <= 1 || step2 <= 1) {
        // 若有一个是1的情况 minStep改成1
        res[0] = 1
      }
      return res
    };
    console.log(Stones(a = 1, b = 2, c = 5))
  </script>
</body>

</html>